function do_hook() {

    var getMD516 = Module.findExportByName("libkeyinfo.so", "getMD516");

    console.log('getMD516 addr = ', getMD516);
    if (getMD516) {
        Interceptor.attach(getMD516, {
            onEnter: function (args) {
                // console.log('2.getMD5参数：', hexdump(args[1], {length: args[2].toInt32()}), "\n");
                // console.log('2.getMD5 参数：', hexdump(args[1]), "\n");
            },
            onLeave: function (retval) {
                // console.log('3.getMD5 返回值：', hexdump(retval), "\n");
                console.log('getMD5=key 返回值：', hexdump(retval, {length: 16}), "\n");
            }
        });
    }

}

function delay_hook(so_name, hook_func) {
    var dlopen = Module.findExportByName(null, "dlopen");
    var android_dlopen_ext = Module.findExportByName(null, "android_dlopen_ext");

    Interceptor.attach(dlopen, {
        onEnter: function (args) {
            var path_ptr = args[0];
            var path = ptr(path_ptr).readCString();
            // console.log("[dlopen:]", path);
            this.path = path;
        }, onLeave: function (retval) {
            if (this.path.indexOf(so_name) !== -1) {
                console.log("[dlopen:]", this.path);
                hook_func();

            }
        }
    });

    Interceptor.attach(android_dlopen_ext, {
        onEnter: function (args) {
            var path_ptr = args[0];
            var path = ptr(path_ptr).readCString();
            this.path = path;
        },
        onLeave: function (retval) {
            if (this.path.indexOf(so_name) !== -1) {
                console.log("\nandroid_dlopen_ext加载：", this.path);
                hook_func();
            }
        }
    });
}

delay_hook("libkeyinfo.so", do_hook);


// frida -H 127.0.0.1:8877 -l  14_hook_so_key.js -f com.achievo.vipshop